package com.samphanie.auiu.auth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.samphanie.auiu.auth.service.IUserRoleService;
import com.samphanie.auiu.mbg.mapper.UserRoleMapper;
import com.samphanie.auiu.mbg.model.SysRole;
import com.samphanie.auiu.mbg.model.UserRole;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * 用户角色关联Service业务层处理
 *
 * @author zsy
 * @date 2021-05-10
 */
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements IUserRoleService {

    @Override
    public Set<SysRole> getRoleList(Long userId) {
        return baseMapper.getRoleList(userId);
    }

    @Override
    public boolean deleteByUserId(Long userId) {
        return remove(new LambdaQueryWrapper<UserRole>().eq(UserRole::getUserId, userId));
    }

    @Override
    public boolean deleteByUserIds(List<Long> ids) {
        return remove(new LambdaQueryWrapper<UserRole>().in(UserRole::getUserId, ids));
    }
}
